<?php

return array(
    'service_manager' => array(
        'factories' => array(
            'Client\Repository\RoleRepository ' => function($sm) {
                $config = $sm->get('Config');
                $roles = isset($config['roles']) ? $config['roles'] : array();
                $roleRepository = new \Client\Repository\InMemoryRoleRepository($roles);
                return $roleRepository;
            },
            'Client\Repository\ClientRepository' => function($sm) {
                $entityManager = $sm->get('Doctrine\ORM\EntityManager');
                $repository = $entityManager->getRepository('Client\Entity\Client');
                return $repository;
            },
            'Client\Form\ClientFilter' => 'Client\Form\ClientFilterFactory',
            'Client\Form\ClientForm' => 'Client\Form\ClientFormFactory',
            'Client\Form\ClientCriteriaFilter' => 'Client\Form\ClientCriteriaFilterFactory',
            'Client\Form\ClientCriteriaForm' => 'Client\Form\ClientCriteriaFormFactory',
        ),
    ),
    'doctrine' => array(
        'driver' => array(
            'client_entities' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
                'paths' => array(__DIR__ . '/../src/Client/Entity')
            ),
            'orm_default' => array(
                'drivers' => array(
                    'Client\Entity' => 'client_entities'
                )
            )
        )
    ),
    'controllers' => array(
        'invokables' => array(
            'Client\Controller\Client' => 'Client\Controller\ClientController',
        ),
    ),
    'roles' => array(
        'helpdesk' => null,
        'technician' => null,
        'admin' => null,
    ),
    'authorization' => array(
        'Client\Controller\Client' => array(
            'index' => 'admin',
            'add' => 'admin',
            'edit' => 'admin',
            'delete' => 'admin',
        ),
    ),
    'router' => array(
        'routes' => array(
            'client' => array(
                'type' => 'segment',
                'options' => array(
                    'route' => '/client[/:action][/:id]',
                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id' => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'Client\Controller\Client',
                        'action' => 'index',
                    ),
                ),
            ),
        ),
    ),
    'navigation' => array(
        'default' => array(
            array(
                'label' => 'Client',
                'route' => 'client',
                'resource' => 'Client\Controller\Client',
                'privilege' => 'index',
            ),
        )
    ),
    'view_manager' => array(
        'template_path_stack' => array(
            'client' => __DIR__ . '/../view',
        ),
    ),
);